package com.yoda.youdianda.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yoda.youdianda.domain.SysRoleMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.context.annotation.Primary;

import java.util.List;

/**
 * @author shawn
 * @date 2022年 11月 16日 0:47
 */
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {

    @Insert({"<script> " +
            "insert into sys_role_menu(sys_role_menu.role_id,sys_role_menu.menu_id) values " +
            "<foreach item = 'menuId' index = 'index' collection='menuIds' separator=','>" +
            "(#{roleId},#{menuId})"+
            "</foreach> " +
            "</script>"})
    int insertList(@Param("roleId") String id,@Param("menuIds") List<Integer> menuIds);

    @Select("select menu_id from sys_role_menu where role_id = #{roleId}")
    List<String> selectMenuByRoleId(String roleId);
    @Delete("delete from sys_role_menu where role_id = #{roleId}")
    void deleteByRoleId(String roleId);
}
